using System;
using System.Windows.Markup;

namespace ChessKit.Common
{
  public class CellExtension : MarkupExtension
  {
    public int X { get; set; }
    public int Y { get; set; }

    public CellExtension() { }

    public CellExtension(string position)
    {
      var pos = Position.Parse(position);
      X = pos.X + 1;
      Y = 8 - pos.Y;
    }

    public CellExtension(int x, int y)
    {
      X = x;
      Y = y;
    }

    public override object ProvideValue(IServiceProvider serviceProvider)
    {
      return BoardLocation.Cell(X, Y);
    }
  }
}